package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class Strategy {
    public static final int STATE_NORMAL = 0;   //正常状态
    public static final int STATE_HOT = 1;   //推荐状态
    public static final int STATE_DISABLE = 2;  //禁用状态

    private Long id;    //id

    private Region place;   //攻略所属地区

    private String title;   //攻略标题

    private String subTitle;    //攻略副标题

    private String coverUrl;    //攻略封面

    private Integer state=STATE_NORMAL;  //攻略状态

    public String getStateDisplay(){
        if(state == STATE_NORMAL){
            return "正常状态";
        }else if(state == STATE_HOT){
            return "推荐状态";
        }else if(state == STATE_DISABLE){
            return "禁用状态";
        }
        return "";
    }

    public String getJsonString(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        if (place != null) {
            map.put("placeId",place.getId());
        }
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }
}